package com.zw.feign.fallBack;

import com.zw.feign.TorderInfoFeign;
import com.zw.pojo.TOrderInfo;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
@Component
public class TorderInfoFallBackFactory implements FallbackFactory<TorderInfoFeign> {


    @Override
    public TorderInfoFeign create(Throwable cause) {
        return new TorderInfoFeign() {
            @Override
            public List<TOrderInfo> firstTest() {
                List<TOrderInfo> list = new ArrayList<>();
                TOrderInfo tOrderInfo = new TOrderInfo();
                tOrderInfo.setOrderCode("这个是HystrixCommand 《降级》提供的避免级联故障或者是雪崩的备选方案");
                list.add(tOrderInfo);
                return list;
            }
        };
    }
}
